//
//  LeftVC.m
//  ZITHER
//
//  Created by weixin on 2018/10/15.
//  Copyright © 2018年 weixn. All rights reserved.
//

#import "LeftVC.h"
//#import "UgcMyLaudVC.h"
//#import "UgcHomePageVC_V3.h"
//#import "MyInterestVC.h"
#import "MyHelpCentre.h"
#import "MeSignatureV.h"

#import "UIViewController+CWLateralSlide.h"

@interface LeftVC ()
@property (nonatomic,strong)BaseBtn * mineBtnMeun;
@property (nonatomic,strong)MeSignatureV * viewSigna;
@end

@implementation LeftVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [UIImage new];
    [self.baseNavigationView setBackgroundColor:[UIColor clearColor]];
    self.baseNavigationView.bottomLineView.backgroundColor = [UIColor clearColor];
    self.baseNavigationView.leftButton1.hidden = YES;
    
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW * 0.75, kScreenH)];
    [self.view addSubview:view];
    
//    [UIColor setDefaulGradiennBackgroundColors:view];
    [self addBtn];
    
        
//    [self addbar];
    
    [self.view addSubview:self.mineBtnMeun];
    
    [self.mineBtnMeun mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(kStatusBarHeight);
        make.left.equalTo(self.view).offset(10);
        make.height.width.mas_equalTo(40);
    }];
    
    [self.view addSubview:self.viewSigna];

    [self.viewSigna mas_makeConstraints:^(MASConstraintMaker *make) {
        //        make.top.equalTo(self.labIsLogin.mas_bottom).offset(10);
        make.left.equalTo(self.view).offset(0);
        make.width.mas_equalTo(kScreenW*0.7);
        make.bottom.equalTo(self.view).offset(-kBottomSafeHeight-10);
        make.height.mas_equalTo(100);
    }];
    

}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
//    self.viewSigna.labSign.text = kUSER_INFO_MANAGER.app_name;
//    self.viewSigna.labContant.text = kUSER_INFO_MANAGER.app_address;
//    self.viewSigna.labVersions.text = kUSER_INFO_MANAGER.ios_version_name;
}

-(void)addbar{
    
    BaseImageV *image = [[BaseImageV alloc]initWithFrame:CGRectMake(14,kScreenH-100,50, 50)];
    
    image.image = [UIImage imageNamed:@"20181102 logo 纯黑"];

    [self.view addSubview:image];
    
//    [self.view addSubview:self.labContant];
//    
//    [self.view addSubview:self.labVersions];
    
}


- (BaseLab *)labContant{
    if (!_labContant) {
        _labContant = [[BaseLab alloc]initializeFrame:CGRectMake(14,kScreenH-100, kScreenW * 0.75-28, 15) text:@"专业腕表" font:12 textColor:[UIColor blackColor] isBold:NO numberOfLines:0];
        _labContant.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:12];
        _labContant.textAlignment = 1;
    }
    return _labContant;
}


- (UILabel *)labVersions{
    if (!_labVersions) {
        _labVersions = [[BaseLab alloc]initializeFrame:CGRectMake(14,kScreenH-80, kScreenW * 0.75-28, 15) text:@"专业腕表" font:12 textColor:[UIColor blackColor] isBold:NO numberOfLines:0];
        _labVersions.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:12];
        _labVersions.textAlignment = 1;
    }
    return _labVersions;
}


-(void)addBtn{
    
    NSArray *arr = @[@"帮助中心",@"黑名单",@"邀请好友"];
    
    for (int i = 0 ; i<3; i++) {
        
        CGRect frame = CGRectMake( 14,100+(45+18)*i, kScreenW * 0.75-28, 45);
        
        BaseBtn *btn = [[BaseBtn alloc]initializeFrame:frame NormalText:arr[i] NormalTextColor:[UIColor blackColor] SeleText:nil SeleTextColor:nil font:16 isBold:NO];
        btn.backgroundColor = [UIColor clearColor];
        [btn setBorderWithColor:[UIColor blackColor] width:1];
        [btn setCornerRadiusWithRadius:7 isMasks:YES];
        [self.view addSubview:btn];
        btn.tag = 100+i;
        @weakify(self);
        [[btn rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self);
            NSLog(@"%@",arr[x.tag-100]);
            if (x.tag == 100) {
                MyHelpCentre *vc = [[MyHelpCentre alloc]init];
                [self cw_pushViewController:vc];
                
//                UgcHomePageVC_V3 *vc = [[UgcHomePageVC_V3 alloc]init];
//                vc.userName = kUSER_INFO_MANAGER.nickName;
//                vc.userId = kUSER_INFO_MANAGER.userId;
//                vc.userAvatar = kUSER_INFO_MANAGER.avatar;
//                [self cw_pushViewController:vc];

            }else if (x.tag == 101){
                [Tools showTips:@"黑名单 UI没出+接口没对"];
//                MyInterestVC *vc = [[MyInterestVC alloc]init];
                
//                [self cw_pushViewController:vc];
            }else{
                [Tools showTips:@"邀请好友 UI没出+接口没对"];

//                UgcMyLaudVC *vc = [[UgcMyLaudVC alloc]init];
                
//                [self cw_pushViewController:vc];
            }
        }];
        
    }
    
    CGRect frame = CGRectMake( 14, 100+(45+18)*3+50, kScreenW * 0.75-28, 45);

    BaseBtn *btn = [[BaseBtn alloc]initializeFrame:frame NormalText:@"退出登录" NormalTextColor:[UIColor blackColor] SeleText:nil SeleTextColor:nil font:16 isBold:NO];
    
    btn.backgroundColor = [UIColor clearColor];
    [btn setBorderWithColor:[UIColor blackColor] width:1];
    [btn setCornerRadiusWithRadius:7 isMasks:YES];
    [self.view addSubview:btn];
    
    @weakify(self);
    [[btn rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
        @strongify(self);
        [self setUPLog];
        /** 退出登陆 */
//        [[AccountService loaduserLoginOut]subscribeNext:^(ResponseData * x) {
//            
//            if (x.success) {
//                [Tools showTips:@"退出成功"];
//            }else{
//                [Tools showTips:x.errorInfo];
//            }
////            [kUSER_INFO_MANAGER saveCookie];
//            [kUSER_INFO_MANAGER removeUserInfo];
//            [kUSER_INFO_MANAGER cleanCookie];
//            kUSER_INFO_MANAGER.getMyEnquiryList = NO;
//            kUSER_INFO_MANAGER.getFollowGoods = NO;
//            [self dismissViewControllerAnimated:YES completion:nil];
//            
//        }];

        
    }];
    
}
-(void)setUPLog{
    [self.mineBtnMeun mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(kStatusBarHeight);
        make.left.equalTo(self.view).offset(10);
        make.height.width.mas_equalTo(40);
    }];
    //移除别名
    [UMessage removeAlias:kUSER_INFO_MANAGER.userId type:@"userId" response:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
        NSLog(@"");
    }];
    [kUSER_INFO_MANAGER saveCookie];
    
    kUSER_INFO_MANAGER.userId = @"";
    [kUSER_INFO_MANAGER removeUserInfo];
    [kUSER_INFO_MANAGER cleanCookie];
    kUSER_INFO_MANAGER.getMyEnquiryList = NO;
    kUSER_INFO_MANAGER.getFollowGoods = NO;
    [self dismissViewControllerAnimated:YES completion:nil];
    
}
-(BaseBtn *)mineBtnMeun{
    if (!_mineBtnMeun) {
        _mineBtnMeun = [[BaseBtn alloc]initializeFrame:CGRectMake(0, 0, 1, 1) NormalText:nil NormalTextColor:nil SeleText:nil NormalImage:@"我的_帮助" SeleImage:nil SeleTextColor:nil font:nil isBold:nil];
        _mineBtnMeun.hidden = YES;
        
        @weakify(self);
        [[_mineBtnMeun rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self);
            MyHelpCentre *vc = [[MyHelpCentre alloc]init];
            [self cw_pushViewController:vc];

//            [self.navigationController pushViewController:vc animated:YES];
            //            [self defaultAnimationFromLeft];
        }];
        [self.view addSubview:_mineBtnMeun];
        
    
        
    }
    return _mineBtnMeun;
}

-(MeSignatureV *)viewSigna{
    if (!_viewSigna) {
        _viewSigna = [[MeSignatureV alloc]initWithFrame:CGRectMake(0,kScreenH-75-48-70,kScreenW,75+48)];
    }
    return _viewSigna;
}

@end
